package com.edu.exam.entity.exampaper.review;

import com.edu.exam.enums.grading.ConfigType;
import com.edu.exam.enums.assessment.generation.Scope;
import com.edu.exam.enums.examination.paper.AlgorithmType;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 试卷查重配置实体类
 * 所属模块：B-03 试卷管理模块
 * 对应数据库表：exam_paper_check_config
 *
 * <p>管理试卷查重的配置参数，包括相似度阈值、算法参数、
 * 权重配置等。支持全局配置和个性化配置。</p>
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class ExamPaperCheckConfig {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 配置名称
     */
    @Column(name = "config_name", nullable = false, length = 100)
    private String configName;

    /**
     * 配置描述
     */
    @Column(name = "config_description", columnDefinition = "TEXT")
    private String configDescription;

    /**
     * 配置类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "config_type", nullable = false, length = 20)
    private ConfigType configType;

    /**
     * 是否激活
     */
    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    /**
     * 是否为默认配置
     */
    @Column(name = "is_default", nullable = false)
    private Boolean isDefault = false;

    /**
     * 适用范围
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "scope", length = 20)
    private Scope scope;

    /**
     * 全局相似度阈值
     */
    @Column(name = "global_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal globalSimilarityThreshold;

    /**
     * 内容相似度阈值
     */
    @Column(name = "content_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal contentSimilarityThreshold;

    /**
     * 结构相似度阈值
     */
    @Column(name = "structure_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal structureSimilarityThreshold;

    /**
     * 题型相似度阈值
     */
    @Column(name = "question_type_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal questionTypeSimilarityThreshold;

    /**
     * 难度相似度阈值
     */
    @Column(name = "difficulty_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal difficultySimilarityThreshold;

    /**
     * 知识点相似度阈值
     */
    @Column(name = "knowledge_point_similarity_threshold", precision = 5, scale = 2)
    private BigDecimal knowledgePointSimilarityThreshold;

    /**
     * 内容相似度权重
     */
    @Column(name = "content_similarity_weight", precision = 3, scale = 2)
    private BigDecimal contentSimilarityWeight;

    /**
     * 结构相似度权重
     */
    @Column(name = "structure_similarity_weight", precision = 3, scale = 2)
    private BigDecimal structureSimilarityWeight;

    /**
     * 题型相似度权重
     */
    @Column(name = "question_type_similarity_weight", precision = 3, scale = 2)
    private BigDecimal questionTypeSimilarityWeight;

    /**
     * 难度相似度权重
     */
    @Column(name = "difficulty_similarity_weight", precision = 3, scale = 2)
    private BigDecimal difficultySimilarityWeight;

    /**
     * 知识点相似度权重
     */
    @Column(name = "knowledge_point_similarity_weight", precision = 3, scale = 2)
    private BigDecimal knowledgePointSimilarityWeight;

    /**
     * 启用试题级查重
     */
    @Column(name = "enable_question_level_check")
    private Boolean enableQuestionLevelCheck = true;

    /**
     * 启用语义分析
     */
    @Column(name = "enable_semantic_analysis")
    private Boolean enableSemanticAnalysis = false;

    /**
     * 启用选项比较
     */
    @Column(name = "enable_options_comparison")
    private Boolean enableOptionsComparison = true;

    /**
     * 启用答案比较
     */
    @Column(name = "enable_answer_comparison")
    private Boolean enableAnswerComparison = true;

    /**
     * 启用解析比较
     */
    @Column(name = "enable_explanation_comparison")
    private Boolean enableExplanationComparison = false;

    /**
     * 忽略标点符号差异
     */
    @Column(name = "ignore_punctuation_diff")
    private Boolean ignorePunctuationDiff = true;

    /**
     * 忽略大小写差异
     */
    @Column(name = "ignore_case_diff")
    private Boolean ignoreCaseDiff = true;

    /**
     * 忽略空格差异
     */
    @Column(name = "ignore_whitespace_diff")
    private Boolean ignoreWhitespaceDiff = true;

    /**
     * 忽略数字差异
     */
    @Column(name = "ignore_number_diff")
    private Boolean ignoreNumberDiff = false;

    /**
     * 最小匹配字符数
     */
    @Column(name = "min_match_chars")
    private Integer minMatchChars = 5;

    /**
     * 最小相似文本长度
     */
    @Column(name = "min_similar_text_length")
    private Integer minSimilarTextLength = 10;

    /**
     * 算法类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "algorithm_type", length = 50)
    private AlgorithmType algorithmType;

    /**
     * 算法版本
     */
    @Column(name = "algorithm_version", length = 50)
    private String algorithmVersion;

    /**
     * 算法参数
     */
    @Column(name = "algorithm_params", columnDefinition = "TEXT")
    private String algorithmParams;

    /**
     * 批处理大小
     */
    @Column(name = "batch_size")
    private Integer batchSize = 100;

    /**
     * 最大并发数
     */
    @Column(name = "max_concurrency")
    private Integer maxConcurrency = 5;

    /**
     * 超时时间(分钟)
     */
    @Column(name = "timeout_minutes")
    private Integer timeoutMinutes = 30;

    /**
     * 重试次数
     */
    @Column(name = "retry_count")
    private Integer retryCount = 3;

    /**
     * 相似度计算精度
     */
    @Column(name = "similarity_precision")
    private Integer similarityPrecision = 2;

    /**
     * 结果缓存时间(分钟)
     */
    @Column(name = "result_cache_minutes")
    private Integer resultCacheMinutes = 60;

    /**
     * 启用结果缓存
     */
    @Column(name = "enable_result_cache")
    private Boolean enableResultCache = true;

    /**
     * 启用增量查重
     */
    @Column(name = "enable_incremental_check")
    private Boolean enableIncrementalCheck = false;

    /**
     * 增量查重时间范围(天)
     */
    @Column(name = "incremental_check_days")
    private Integer incrementalCheckDays = 30;

}
